﻿using AutoMapper;
using Blog.Core3.Model.VeiwModels;
using Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Blog.Core3.AutoMapper
{
    /// <summary>
    ///  配置构造函数，用来创建关系映射
    /// </summary>
    public class CustomProfile : Profile
    {
        #region  解释
        //Profile不知有什么用，通过百度了解才了解是services.AddAutoMapper是会自动找到所有继承了Profile的类然后进行配置，
        //而且我的这个配置文件是在api层的，如果Profile配置类放在别的层（比如Service层），
        //如果没解耦的话，可以services.AddAutoMapper()，参数留空，
        //AutoMapper会从所有引用的程序集里找继承Profile的类，如果解耦了，就得services.AddAutoMapper(Assembly.Load("Blog.Core.Service"))。
        #endregion

        /// <summary>
        /// 配置构造函数，用来创建关系映射
        /// </summary>
        public CustomProfile()
        {
            //public IMappingExpression<TSource, TDestination> CreateMap<TSource, TDestination>()； 源代码
            CreateMap<ArticleInfo, BlogArticleShowViewModel>()
                 //.ForMember(dest => dest.UserAccount, opt => opt.Ignore())
                 //.ForMember(dest => dest.ArticleIsDelete, opt => opt.Ignore())
                 //.ForMember(dest => dest.ArticleIsRelease, opt => opt.Ignore())
                 //.ForMember(dest => dest.ArticleIsDelete, opt => opt.Ignore())
                 //.ForMember(dest => dest.UserAccount, opt => opt.Ignore())
                 //.ForMember(dest => dest.PrevTitie, opt => opt.Ignore())
                 //.ForMember(dest => dest.Prev, opt => opt.Ignore())
                 //.ForMember(dest => dest.NextTitie, opt => opt.Ignore())
                 //.ForMember(dest => dest.Next, opt => opt.Ignore())
                 //.ForMember(dest => dest.ID, opt => opt.Ignore())
                ;
        }
    }
}
